package com.oa.gongwen.dao;

import com.oa.gongwen.entity.AuditPerson;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

@MapperScan
public interface AuditPersonMapper {
    @Delete({
        "delete from audit_person",
        "where ap_id = #{apId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer apId);

    @Insert({
        "insert into audit_person (ap_id, person, ",
        "gongwen_id, opinion, ",
        "ap_agree, ap_audit_grade)",
        "values (#{apId,jdbcType=INTEGER}, #{person,jdbcType=VARCHAR}, ",
        "#{gongwenId,jdbcType=INTEGER}, #{opinion,jdbcType=VARCHAR}, ",
        "#{apAgree,jdbcType=INTEGER}, #{apAuditGrade,jdbcType=VARCHAR})"
    })
    int insert(AuditPerson record);

    int insertSelective(AuditPerson record);

    @Select({
        "select",
        "ap_id, person, gongwen_id, opinion, ap_agree, ap_audit_grade",
        "from audit_person",
        "where gongwen_id = #{gongwenId,jdbcType=INTEGER}"
    })
    @ResultMap("com.oa.gongwen.dao.AuditPersonMapper.BaseResultMap")
    List<AuditPerson> selectByGongwenid(Integer apId);

    int updateByPrimaryKeySelective(AuditPerson record);

    @Update({
        "update audit_person",
        "set person = #{person,jdbcType=VARCHAR},",
          "gongwen_id = #{gongwenId,jdbcType=INTEGER},",
          "opinion = #{opinion,jdbcType=VARCHAR},",
          "ap_agree = #{apAgree,jdbcType=INTEGER},",
          "ap_audit_grade = #{apAuditGrade,jdbcType=VARCHAR}",
        "where ap_id = #{apId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(AuditPerson record);
}